package io.gitee.kenewstar.dbmq.util;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.RandomUtil;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;

/**
 * @author kenewstar
 */
public abstract class Util {

    public static Integer getNewTag(List<Integer> tags) {
        if (CollUtil.isEmpty(tags)) {
            return 1;
        }
        return tags.get(RandomUtil.randomInt(tags.size()));
    }

    public static String getIpAddress() {
        try {
            return InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return "0.0.0.0";
    }


}
